﻿using System;
using System.Collections.Generic;
using System.Collections;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Telerik.Web.UI;
using KPIS.GERP.GHRMS.BLL;
using KPIS.GERP.GHRMS.IBLL;

namespace KPIS.GERP.GHRMS.APP.App_UI.UserControls
{
    public partial class RC_CommandFormats : System.Web.UI.UserControl
    {
        private SsMng ssMng = new SsMng();
        private ICommandTypeBLL cmdBLL = new CommandTypeBLL();
        private object _dataItem = null;

        protected void Page_Load(object sender, EventArgs e)
        {

        }
        public object DataItem
        {
            get
            {
                return this._dataItem;
            }
            set
            {
                this._dataItem = value;
            }
        }
        protected bool IsUserControlPostBack
        {
            get
            {
                return this.ViewState["IsUserControlPostBack"] != null;
            }
        }

        protected override void OnLoad(System.EventArgs e)
        {
            base.OnLoad(e);

            if (!IsUserControlPostBack)
            {
                this.ViewState.Add("IsUserControlPostBack", true);
            }

            if (DataItem != null)
            {
                if (!(DataItem is Telerik.Web.UI.GridInsertionObject))
                {
                    lblSequence.Text = DataBinder.Eval(DataItem, "CMD_TYPE_SEQ").ToString();
                    txtReportTitle.Text = DataBinder.Eval(DataItem, "RPT_HEADER").ToString();
                    txtName.Text = DataBinder.Eval(DataItem, "RPT_FORMAT").ToString();
                }
            }
        }

        protected void btnAddnew_Click(object sender, EventArgs e)
        {
            cmdBLL.UpdateFormat(Int32.Parse(lblSequence.Text), txtReportTitle.Text, txtName.Text, ssMng.EmpSeqI);
        }

        protected void btnUpdate_Click(object sender, EventArgs e)
        {
            cmdBLL.UpdateFormat(Int32.Parse(lblSequence.Text), txtReportTitle.Text, txtName.Text, ssMng.EmpSeqI);
        }

        protected void btnCancel_Click(object sender, EventArgs e)
        {

        }
    }
}